package com.itany.corejava.code10_异常;

/**
 * @author 石小俊
 * @date 2023年05月09日 16:12
 */
public class Test07_debug的使用 {

    public static void main(String[] args) {
        UserService userService = new UserService();
        try {
            userService.register("aaa","123");
        } catch (UserExistException e) {
            e.printStackTrace();
        }
    }

}

class UserDao{
    public void insertUser(String username,String password) throws UserExistException {
        if("admin".equals(username)){
            throw new UserExistException("该用户已经被注册");
        }
        System.out.println("注册成功");
    }
}
class UserService{
    UserDao userDao = new UserDao();
    public void register(String username,String password) throws UserExistException {
        for(int i = 0; i < 4; i++){
            System.out.println(i);
            int j = i - 2;
            j = i / j;
        }
        userDao.insertUser(username,password);
    }
}
